package com.supcon.exchangedata.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author ：icerain.gan
 * @date ：Created in 2020/3/10 17:05
 * @description：读取数据源信息
 * @modified By：
 * @version: 1.0$
 */
@Configuration
public class DataSourceConfig {



        @Bean(name = "primaryDataSource")
        @Qualifier("primaryDataSource")
        @Primary
        @ConfigurationProperties(prefix = "spring.datasource.primary")
        public DataSource primaryDataSource() {
            return DataSourceBuilder.create().build();
        }

        @Bean(name = "secondaryDataSource")
        @Qualifier("secondaryDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.secondary")
        public DataSource secondaryDataSource() {
            return DataSourceBuilder.create().build();
        }

        @Bean(name = "thirdDataSource")
        @Qualifier("thirdDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.third")
        public DataSource thirdDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "fourDataSource")
        @Qualifier("fourDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.four")
        public DataSource fourDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "swDataSource")
        @Qualifier("swDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.sw")
        public DataSource swDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "gjDataSource")
        @Qualifier("gjDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.gj")
        public DataSource gjDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "rqDataSource")
        @Qualifier("rqDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.rq")
        public DataSource rqDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "hjDataSource")
        @Qualifier("hjDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.hj")
        public DataSource hjDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "lqDataSource")
        @Qualifier("lqDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.lq")
        public DataSource lqDataSource() {
                return DataSourceBuilder.create().build();
        }

        @Bean(name = "cjfzDataSource")
        @Qualifier("cjfzDataSource")
        @ConfigurationProperties(prefix = "spring.datasource.cjfz")
        public DataSource cjfzDataSource() {
                return DataSourceBuilder.create().build();
        }



}
